/**
 * @description 定义商品和购物车相关Api
 */

import { CART_ADD_URL, CART_LIST_URL, GOODS_DETAILS_URL, GOODS_SEARCH_URL, GOOGS_ASSORT_URL, GOOGS_LIST_URL, GOOGS_TYPE_URL } from "../config/urls.cfg";
import request from "./ajax";

/** 商品列表Api */
export function getGoodsApi(type: string) {
    return request({
        url: GOOGS_LIST_URL,
        params: { type }
    })
}

/** 商品分类Api */
export function goodsAssortApi() {
    return request({
        url: GOOGS_ASSORT_URL
    })
}

/** 商品某一类数据Api */
export function goodsTypeApi(type: string) {
    return request({
        url: GOOGS_TYPE_URL,
        params: { type }
    })
}

/** 商品详情Api */
export function goodsDetailsApi(id: string) {
    return request({
        url: GOODS_DETAILS_URL,
        params: { id }
    })
}

/** 商品搜索Api */
export function goodsSearchApi(des: string) {
    return request({
        url: GOODS_SEARCH_URL,
        params: { des }
    })
}

/** 添加购物车Api */
export function cartAddApi(data: any) {
    return request({
        url: CART_ADD_URL,
        method: 'PUT',
        data
    })
}

/** 获取购物车列表Api */
export function cartListApi(uid: string) {
    return request({
        url: CART_LIST_URL,
        params: { uid }
    })
}